Update EIP-6551: Preventing circular lock situation with initialize #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request adds the
initializefunction for EIP-6551 as described in the guidelines. Theinitializefunction can be called by the owner after ownership change to set thecurrOwnerandprevOwnervariables. Additionally, theunlockCircularLockfunction is introduced to handle situations of circular lock, allowing the previous owner to unlock it.Changes
Added Functions
initialize(uint256 tokenId) external: Initializes thecurrOwnerandprevOwnervariables after ownership change.unlockCircularLock(uint256 tokenId) external: Allows the previous owner to unlock the circular lock situation by calling this function.Modifications
ERC6551Accountcontract to include the new variablescurrOwnerandprevOwner.Tests
initializeandunlockCircularLockfunctions.Motivation
This enhancement is in line with the objectives of EIP-6551 and provides additional functionalities for handling ownership transitions and circular lock scenarios.
Usage
After ownership change, the new owner can call the
initializefunction to set the current owner (currOwner) and previous owner (prevOwner) variables.In cases of circular lock, the previous owner can use the
unlockCircularLockfunction to release the lock.Issues
The
initializefunction could only be used to changepreviousOwner. and this value could only be used for account recovery. however if new owner of Token transfer it to another owner without initialization, thepreviousOwneris not changed, hence the recovery can be done by third last owner and he can call it without any restriction, which could be malicious.Checklist